from django import forms
from django.contrib.auth.forms import AuthenticationForm
######## 导入模型 #########
from .models import tool_beiwang,tool_user_zhanneixin


class LoginForm(AuthenticationForm):
    username = forms.CharField(label="用户名", widget=forms.TextInput(attrs={'autofocus': True}))
    password = forms.CharField(label="密码", widget=forms.PasswordInput)


class UploadFileForm(forms.Form):
    """上传文件的表单*(导入功能)"""
    file = forms.FileField()


class tool_BeiWang_Form(forms.ModelForm):
    class Meta:
        model = tool_beiwang
        fields = ['title', 'content', 'leixing', 'tixing_time']
        labels = {'title': "标题", 'content': "内容"}
        widgets = {
            'title': forms.TextInput(attrs={'class': 'form-control'}),
            'content': forms.Textarea(attrs={'rows': 10, 'cols': 80, 'class': 'form-control'}),
            'leixing': forms.Select(attrs={'class': 'form-select'}),
            'tixing_time': forms.DateTimeInput(attrs={'type': 'date', 'class': 'form-control'})
        }

class tool_zhanneixin_Form(forms.ModelForm):
    class Meta:
        model = tool_user_zhanneixin
        fields = ['title', 'content', 'leixing','jieshouren']
        labels = {'title': "标题", 'content': "内容"}
        widgets = {
            'title': forms.TextInput(attrs={'class': 'form-control'}),
            'content': forms.Textarea(attrs={'rows': 10, 'cols': 80, 'class': 'form-control'}),
            'leixing': forms.Select(attrs={'class': 'form-select'}),
            'jieshouren': forms.SelectMultiple(attrs={'class': 'form-select'}),
        }
